package com.aaa.java14;

import cn.hutool.core.lang.hash.Hash;

import java.util.HashMap;
import java.util.Map;

/**
 * @author ：Teacher陈（86521760@qq.com）
 * @date ：Created in 2022/7/18 11:10
 * @description：
 * @modified By：
 * @version:
 */
public class MapObjectTest {

    public static void main(String[] args) {
       /* //构建了一个空的map集合
        Map<Integer,Teacher> teacherMap = new HashMap<>();
        Teacher teacher1= new Teacher(1000,"zhangsan1",2000);
        Teacher teacher2= new Teacher(1002,"zhangsan2",3000);
        Teacher teacher3= new Teacher(1001,"zhangsan3",1800);
        teacherMap.put(1,teacher1);
        teacherMap.put(2,teacher2);
        teacherMap.put(3,teacher3);
        System.out.println(teacherMap);

        //通过key获取值
        Teacher teacher = teacherMap.get(2);
        System.out.println(teacher);
        //通过value获取
        boolean containsValue = teacherMap.containsValue(new Teacher(1002,"zhangsan2",3000));
        System.out.println(containsValue);*/
        //构建了一个空的map集合
        Map<Teacher,Teacher> teacherMap = new HashMap<>();
        Teacher teacher1= new Teacher(1000,"zhangsan1",2000);
        Teacher teacher2= new Teacher(1002,"zhangsan2",3000);
        Teacher teacher3= new Teacher(1001,"zhangsan3",1800);
        teacherMap.put(teacher1,teacher1);
        teacherMap.put(teacher2,teacher2);
        teacherMap.put(teacher3,teacher3);
        System.out.println(teacherMap);

        //通过key获取值
        Teacher teacher = teacherMap.get(teacher2);
        System.out.println(teacher);
        //通过value获取
        boolean containsValue = teacherMap.containsValue(new Teacher(1002,"zhangsan2",3000));
        System.out.println(containsValue);
    }

}
